extends Control

# 保存
func _on_button_1_pressed():
	var root := Area2D.new()
	root.name = "Player"

	var collider = CollisionShape2D.new()
	root.add_child(collider)
	collider.name = "CollisionShape2D"
	collider.owner = root
	
	# 创建一个新的CircleShape2D用于碰撞形状
	var circle_shape = CircleShape2D.new()
	circle_shape.radius = 80 # 设置圆的半径
	collider.shape = circle_shape

	var sprite = Sprite2D.new()
	root.add_child(sprite)
	sprite.name = "Sprite"
	sprite.owner = root
	var texture = load("res://icon.svg")
	sprite.texture = texture

	var scene = PackedScene.new()
	scene.pack(root)

	ResourceSaver.save(scene, "res://save_game2/player.tscn")

# 加载
func _on_button_2_pressed():
	var scene:PackedScene = load("res://save_game2/player.tscn")
	var node = scene.instantiate()
	node.position = Vector2(100, 100)
	add_child(node)
